include $(RT28xx_OS_DIR)/linux/config.mk

RT28xx_RPATH = ../../
RT28xx_EMBED_RPATH=../../embedded

obj_ap :=
obj_sta :=
obj_p2p :=
obj_wsc :=
obj_vht :=
obj_cmm := \
        $(RT28xx_EMBED_RPATH)/security/crypt_md5.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_sha2.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_hmac.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_aes.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_arc4.o\
        $(RT28xx_EMBED_RPATH)/common/mlme.o\
        $(RT28xx_EMBED_RPATH)/security/cmm_wep.o\
        $(RT28xx_EMBED_RPATH)/common/action.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_data.o\
        $(RT28xx_EMBED_RPATH)/common/qm.o\
        $(RT28xx_EMBED_RPATH)/common/fp_qm.o\
		$(RT28xx_EMBED_RPATH)/common/fq_qm.o\
		$(RT28xx_EMBED_RPATH)/common/fp_fair_qm.o\
        $(RT28xx_EMBED_RPATH)/common/rtmp_init.o\
        $(RT28xx_EMBED_RPATH)/common/rtmp_init_inf.o\
        $(RT28xx_EMBED_RPATH)/security/cmm_tkip.o\
        $(RT28xx_EMBED_RPATH)/security/cmm_aes.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_sync.o\
        $(RT28xx_EMBED_RPATH)/common/eeprom.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_sanity.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_info.o\
        $(RT28xx_EMBED_RPATH)/common/icap.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_cfg.o\
        $(RT28xx_EMBED_RPATH)/security/cmm_wpa.o\
        $(RT28xx_EMBED_RPATH)/security/cmm_sec.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_radar.o\
        $(RT28xx_EMBED_RPATH)/common/spectrum.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_mumimo.o\
        $(RT28xx_EMBED_RPATH)/common/rtmp_timer.o\
        $(RT28xx_EMBED_RPATH)/common/rt_channel.o\
        $(RT28xx_EMBED_RPATH)/common/ee_efuse.o\
        $(RT28xx_EMBED_RPATH)/common/ee_prom.o\
        $(RT28xx_EMBED_RPATH)/common/ee_flash.o\
		$(RT28xx_EMBED_RPATH)/common/op_class.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_profile.o\
        $(RT28xx_EMBED_RPATH)/common/scan.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_cmd.o\
		$(RT28xx_EMBED_RPATH)/common/ps.o\
		$(RT28xx_EMBED_RPATH)/common/sys_log.o\
		$(RT28xx_EMBED_RPATH)/common/txpower.o\
        $(RT28xx_RPATH)/chips/rtmp_chip.o\
        $(RT28xx_EMBED_RPATH)/mgmt/mgmt_hw.o\
        $(RT28xx_EMBED_RPATH)/mgmt/mgmt_dev.o\
        $(RT28xx_EMBED_RPATH)/mgmt/mgmt_entrytb.o\
        $(RT28xx_EMBED_RPATH)/common/wdev.o\
		$(RT28xx_EMBED_RPATH)/common/bcn.o\
        $(RT28xx_EMBED_RPATH)/common/wifi_sys_info.o\
        $(RT28xx_EMBED_RPATH)/common/wifi_sys_notify.o\
		$(RT28xx_EMBED_RPATH)/wlan_config/config_basic.o\
		$(RT28xx_EMBED_RPATH)/wlan_config/config_phy.o\
		$(RT28xx_EMBED_RPATH)/wlan_config/config_ht.o\
		$(RT28xx_EMBED_RPATH)/wlan_config/config_vht.o\
		$(RT28xx_EMBED_RPATH)/mgmt/be_basic.o\
		$(RT28xx_EMBED_RPATH)/mgmt/be_phy.o\
		$(RT28xx_EMBED_RPATH)/mgmt/be_ht.o\
		$(RT28xx_EMBED_RPATH)/mgmt/be_vht.o\
        $(RT28xx_EMBED_RPATH)/mgmt/bss_ops.o\
		$(RT28xx_EMBED_RPATH)/common/cmm_rvr_dbg.o\
        $(RT28xx_EMBED_RPATH)/common/cmm_info_element.o\
		$(RT28xx_RPATH)/os/linux/rt_profile.o\
		$(RT28xx_RPATH)/os/linux/tm.o\
	$(RT28xx_EMBED_RPATH)/common/misc_app.o

#ifdef RTMP_UDMA_SUPPORT
ifeq ($(HAS_INTEL_UDMA_SUPPORT),y)
obj_cmm += $(RT28xx_RPATH)/os/linux/rt_udma.o
endif
#endif // RTMP_UDMA_SUPPORT //

ifeq ($(HAS_CUT_THROUGH),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/cut_through.o
endif

ifeq ($(HAS_TCP_RACK_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/cmm_tcprack.o
endif

ifeq ($(HAS_SINGLE_SKU_V2_SUPPORT),y)
obj_cmm += $(RT28xx_RPATH)/txpwr/single_sku.o
endif

ifeq ($(HAS_FW_DUMP_SUPPORT),y)
obj_cmm += $(RT28xx_RPATH)/os/linux/mt_fwdump.o
endif

ifeq ($(HAS_MULTI_PROFILE_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/multi_profile.o
endif

obj_ra := \
	$(RT28xx_RPATH)/rate_ctrl/ra_ctrl_mt.o\
	$(RT28xx_RPATH)/rate_ctrl/ra_ctrl_mt_drv.o\
	$(RT28xx_RPATH)/rate_ctrl/ra_wrapper_embedded.o\
	$(RT28xx_RPATH)/rate_ctrl/ra_cfg.o

ifeq ($(HAS_RACTRL_FW_OFFLOAD_SUPPORT),n)
obj_ra +=  $(RT28xx_RPATH)/rate_ctrl/ra_table.o
endif

obj_txbf := \
    $(RT28xx_RPATH)/txbf/cmm_txbf_cal_mt.o\
	$(RT28xx_RPATH)/txbf/cmm_txbf_mt.o\
	$(RT28xx_RPATH)/txbf/txbf_wrapper_embedded.o

obj_hw_ctrl := \
	$(RT28xx_RPATH)/hw_ctrl/cmm_asic.o \
	$(RT28xx_RPATH)/hw_ctrl/cmm_chip.o \
	$(RT28xx_RPATH)/hw_ctrl/hw_init.o

ifeq ($(HAS_GREENAP_SUPPORT),y)
obj_hw_ctrl +=  $(RT28xx_RPATH)/hw_ctrl/greenap.o
endif
#########################################
#   ASIC related source files
#########################################
obj_mac :=
obj_phy := $(RT28xx_RPATH)/phy/phy.o\
		$(RT28xx_RPATH)/phy/rf.o

ifeq ($(HAS_MT_BBP),y)
obj_phy += $(RT28xx_RPATH)/phy/mt_phy.o
endif

ifeq ($(HAS_RLM_CAL_CACHE),y)
obj_phy += $(RT28xx_RPATH)/phy/rlm_cal_cache.o
endif

ifeq ($(HAS_MT_RF),y)
obj_phy += $(RT28xx_RPATH)/phy/mt_rf.o
endif

ifeq ($(HAS_MAC_PCI),y)
obj_mac += $(RT28xx_EMBED_RPATH)/common/cmm_mac_pci.o\
	$(RT28xx_EMBED_RPATH)/common/hif_pci.o\
	$(RT28xx_RPATH)/os/linux/rt_rbus_pci_drv.o

ifeq ($(HAS_ATE),y)
#obj_mac += $(RT28xx_EMBED_RPATH)/ate/rt_mac/ate_pci.o
endif

ifeq ($(OSABL),NO)
obj_mac += \
	$(RT28xx_RPATH)/os/linux/rt_pci_rbus.o\
	$(RT28xx_RPATH)/os/linux/rt_rbus_pci_util.o
endif
endif



ifeq ($(HAS_MT_MAC),y)
obj_mac += $(RT28xx_RPATH)/hw_ctrl/cmm_chip_mt.o
obj_mac += $(RT28xx_RPATH)/hw_ctrl/mt_gpio.o
ifneq ($(findstring mt7615,$(CHIPSET)),)
obj_mac += $(RT28xx_RPATH)/mac/mt_dmac.o
obj_mac += $(RT28xx_RPATH)/hw_ctrl/cmm_asic_mt_dmac.o
else #mt7615
ifeq ($(CHIPSET), $(filter $(CHIPSET), p18 mt7622 mt7663 soc1_0))
obj_mac += $(RT28xx_RPATH)/mac/mt_dmac.o
obj_mac += $(RT28xx_RPATH)/hw_ctrl/cmm_asic_mt_dmac.o
else #p18
obj_mac += $(RT28xx_RPATH)/mac/mt_mac.o
obj_mac += $(RT28xx_RPATH)/hw_ctrl/cmm_asic_mt.o
endif #p18
endif #mt7615
obj_mac += $(RT28xx_RPATH)/hw_ctrl/cmm_asic_mt_fw.o
obj_mac += $(RT28xx_EMBED_RPATH)/common/mt_ps.o
obj_mac += $(RT28xx_EMBED_RPATH)/common/mt_io.o
obj_mac += $(RT28xx_RPATH)/protocol/tmr.o
obj_mac += $(RT28xx_RPATH)/protocol/protection.o
obj_mac += $(RT28xx_EMBED_RPATH)/common/txs.o
endif


#########################################
#   Itnterface related source files
#########################################
obj_inf :=

obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hw_ctrl.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hw_ctrl_basic.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hw_ctrl_cmd.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev/wmm_ctrl.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev/wtbl_ctrl.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev/radio_ctrl.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev/omac_ctrl.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev/hdev_basic.o
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hdev_ctrl.o

ifeq ($(HAS_WIFI_SYS_FW_V1),y)
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hw_ctrl_ops_v1.o
endif

ifeq ($(HAS_WIFI_SYS_FW_V2),y)
obj_inf +=$(RT28xx_EMBED_RPATH)/hw_ctrl/hw_ctrl_ops_v2.o
endif



ifeq ($(HAS_INF_PCI),y)
ifeq ($(OSABL),NO)
obj_inf += $(RT28xx_RPATH)/os/linux/pci_main_dev.o
endif
endif

ifeq ($(HAS_INF_RBUS),y)
ifeq ($(OSABL),NO)
obj_inf += $(RT28xx_RPATH)/os/linux/rbus_main_dev.o
endif
endif

obj_cmm += $(obj_phy) $(obj_mac) $(obj_inf) $(obj_hw_ctrl)

#########################################
# ATE/QA related source files
#########################################
ifeq ($(HAS_ATE),y)
obj_cmm += $(RT28xx_RPATH)/ate/ate_agent.o

ifeq ($(HAS_QA_SUPPORT),y)
#obj_cmm += $(RT28xx_RPATH)/ate/qa_agent.o
obj_cmm += $(RT28xx_RPATH)/ate/testmode_ioctl.o
obj_cmm += $(RT28xx_RPATH)/ate/LoopBack.o
endif
endif


#########################################
#   System Feature related source files
#########################################

ifeq ($(HAS_UAPSD_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/uapsd.o
endif

ifeq ($(HAS_BLOCK_NET_IF),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/netif_block.o
endif

ifeq ($(HAS_NEW_RATE_ADAPT_SUPPORT),y)
obj_ra += $(RT28xx_RPATH)/rate_ctrl/alg_grp_mt.o
endif

ifeq ($(HAS_RATE_ADAPT_AGBS_SUPPORT),y)
ifeq ($(HAS_RACTRL_FW_OFFLOAD_SUPPORT),n)
obj_ra += $(RT28xx_RPATH)/rate_ctrl/alg_agbs_mt.o
obj_ra += $(RT28xx_RPATH)/rate_ctrl/ra_fallback_mt.o
endif
endif

ifeq ($(HAS_DFS_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/cmm_dfs.o
endif

ifeq ($(HAS_MT_DFS_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/cmm_rdm_mt.o
endif

ifeq ($(HAS_CS_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/cmm_cs.o
endif

#ifdef LED_CONTROL_SUPPORT
ifeq ($(HAS_LED_CONTROL_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/rt_led.o
endif
#endif // LED_CONTROL_SUPPORT //

#ifdef ANDES_FIRMWARE_SUPPORT
ifeq ($(HAS_ANDES_FIRMWARE_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/mcu/rtmp_and.o
endif
#endif /* ANDES_FIRMWARE_SUPPORT */


#ifdef DOT11_SAE_SUPPORT
ifeq ($(HAS_WPA3_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/security/sae.o
obj_cmm += $(RT28xx_EMBED_RPATH)/security/bn_lib.o
obj_cmm += $(RT28xx_EMBED_RPATH)/security/crypt_bignum.o
obj_cmm += $(RT28xx_EMBED_RPATH)/security/crypt_biginteger.o
obj_cmm += $(RT28xx_EMBED_RPATH)/security/ecc.o
ifeq ($(HAS_OWE_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/security/owe.o
endif
endif
#endif

#ifdef DOT11K_RRM_SUPPORT
ifeq ($(HAS_DOT11K_RRM_SUPPORT),y)
obj_cmm += \
	$(RT28xx_EMBED_RPATH)/common/rrm_tlv.o\
	$(RT28xx_EMBED_RPATH)/common/rrm_sanity.o\
	$(RT28xx_EMBED_RPATH)/common/rrm.o
endif
#endif // DOT11K_RRM_SUPPORT //

#ifdef CONFIG_DOT11V_WNM
ifeq ($(HAS_DOT11V_WNM_SUPPORT),y)
obj_cmm += \
    $(RT28xx_EMBED_RPATH)/common/wnm.o
endif
#endif // CONFIG_DOT11V_WNM //

#ifdef DOT11W_PMF_SUPPORT
ifeq ($(HAS_DOT11W_PMF_SUPPORT),y)
obj_cmm += $(RT28xx_EMBED_RPATH)/security/pmf.o
endif
#endif // DOT11W_PMF_SUPPORT //


#ifdef DOT11_N_SUPPORT
ifeq ($(HAS_DOT11_N_SUPPORT),y)
obj_cmm += \
        $(RT28xx_EMBED_RPATH)/common/ba_action.o\
        $(RT28xx_EMBED_RPATH)/mgmt/mgmt_ht.o\
	$(RT28xx_EMBED_RPATH)/common/vendor.o

#ifdef TXBF_SUPPORT
ifeq ($(HAS_TXBF_SUPPORT),y)
#ifdef MT_MAC
ifeq ($(HAS_MT_MAC),n)
obj_cmm += \
        $(RT28xx_EMBED_RPATH)/common/cmm_txbf.o
endif
#endif // MT_MAC //
endif
#endif // TXBF_SUPPORT //
endif
#endif // DOT11_N_SUPPORT //

#ifdef DOT11_VHT_SUPPORT
ifeq ($(HAS_DOT11_VHT_SUPPORT),y)
obj_vht += $(RT28xx_EMBED_RPATH)/mgmt/mgmt_vht.o\
	$(RT28xx_EMBED_RPATH)/common/vht.o
endif
#endif // DOT11_VHT_SUPPORT //


#ifdef WSC_INCLUDED
ifeq ($(HAS_WSC),y)
obj_wsc += \
        $(RT28xx_EMBED_RPATH)/common/wsc.o\
        $(RT28xx_EMBED_RPATH)/common/wsc_tlv.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_biginteger.o\
        $(RT28xx_EMBED_RPATH)/security/crypt_dh.o
endif

ifeq ($(HAS_WSC_V2),y)
obj_wsc += $(RT28xx_EMBED_RPATH)/common/wsc_v2.o
endif
ifeq ($(HAS_WSC_NFC),y)
obj_wsc += $(RT28xx_EMBED_RPATH)/common/nfc.o
endif
#endif // WSC_INCLUDED //

#ifdef DOT11R_FT_SUPPORT
ifeq ($(HAS_DOT11R_FT_SUPPORT),y)
obj_cmm += \
	$(RT28xx_EMBED_RPATH)/common/ft.o\
	$(RT28xx_EMBED_RPATH)/common/ft_tlv.o\
	$(RT28xx_EMBED_RPATH)/common/ft_iocl.o\
	$(RT28xx_EMBED_RPATH)/common/ft_rc.o
endif
#endif // DOT11R_FT_SUPPORT //



#ifdef CONFIG_HOTSPOT
ifeq ($(HAS_HOTSPOT_SUPPORT),y)
obj_cmm += \
		$(RT28xx_EMBED_RPATH)/common/wnm.o\
		$(RT28xx_EMBED_RPATH)/common/gas.o\
		$(RT28xx_EMBED_RPATH)/common/hotspot.o
endif
#endif // CONFIG_HOTSPOT //


#ifdef SMART_CARRIER_SENSE_SUPPORT
ifeq ($(HAS_SMART_CARRIER_SENSE_SUPPORT),y)
obj_cmm += \
        $(RT28xx_EMBED_RPATH)/common/scs.o
endif
#endif // SMART_CARRIER_SENSE_SUPPORT //

###############################################################################
#
# config for AP mode
#
###############################################################################

#ifdef CONFIG_AP_SUPPORT
ifeq ($(RT28xx_MODE),AP)
obj_ap += \
	$(RT28xx_EMBED_RPATH)/ap/ap_mbss.o\
	$(RT28xx_EMBED_RPATH)/ap/ap.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_assoc.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_auth.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_mlme.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_sanity.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_sync.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_wpa.o\
    $(RT28xx_EMBED_RPATH)/ap/ap_sec.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_data.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_autoChSel.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_qload.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_cfg.o\
	$(RT28xx_EMBED_RPATH)/ap/ap_nps.o\
        $(RT28xx_EMBED_RPATH)/ap/ap_vow.o

ifeq ($(HAS_MU_MIMO_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_mumimo.o
endif

ifeq ($(HAS_IDS_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_ids.o
endif

#ifdef CONFIG_WAPP_SUPPORT
ifeq ($(HAS_WAPP_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/wapp/wapp.o
endif
#endif // CONFIG_WAPP_SUPPORT //

#ifdef CONFIG_MBO_SUPPORT
ifeq ($(HAS_MBO_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/common/mbo.o
endif
#endif // CONFIG_MBO_SUPPORT //

#ifdef CONFIG_MAP_SUPPORT
ifeq ($(HAS_MAP_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/common/map.o
obj_ap += $(RT28xx_EMBED_RPATH)/common/a4_conn.o
obj_ap += $(RT28xx_EMBED_RPATH)/common/routing_tab.o
endif
#endif // CONFIG_MAP_SUPPORT //

ifeq ($(HAS_WSC),y)
obj_ap += $(RT28xx_EMBED_RPATH)/common/wsc_ufd.o
endif

#ifdef DOT11R_FT_SUPPORT
ifeq ($(HAS_DOT11R_FT_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_ftkd.o
endif
#endif // DOT11R_FT_SUPPORT //


ifeq ($(HAS_WDS),y)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_wds.o

ifeq ($(OSABL),NO)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_wds_inf.o
endif
endif

ifeq ($(OSABL),NO)
obj_ap += \
    $(RT28xx_EMBED_RPATH)/ap/ap_mbss_inf.o\
	$(RT28xx_RPATH)/os/linux/ap_ioctl.o
endif

ifeq ($(HAS_MWDS),y)
obj_ap += \
    $(RT28xx_EMBED_RPATH)/common/mwds.o \
    $(RT28xx_EMBED_RPATH)/common/routing_tab.o
endif

ifeq ($(HAS_WH_EVENT_NOTIFIER),y)
obj_ap += \
    $(RT28xx_EMBED_RPATH)/common/event_notifier.o
endif

#ifdef APCLI_SUPPORT
ifeq ($(HAS_APCLI),y)
obj_ap += \
	$(RT28xx_EMBED_RPATH)/ap/ap_apcli.o \
	$(RT28xx_EMBED_RPATH)/ap/apcli_ctrl.o \
	$(RT28xx_EMBED_RPATH)/ap/apcli_sync.o \
	$(RT28xx_EMBED_RPATH)/ap/apcli_auth.o \
	$(RT28xx_EMBED_RPATH)/ap/apcli_assoc.o \
	$(RT28xx_EMBED_RPATH)/common/cmm_mat.o \
	$(RT28xx_EMBED_RPATH)/common/cmm_mat_iparp.o \
	$(RT28xx_EMBED_RPATH)/common/cmm_mat_pppoe.o \
	$(RT28xx_EMBED_RPATH)/common/cmm_mat_ipv6.o


ifeq ($(HAS_MAC_REPEATER_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_repeater.o
endif

ifeq ($(OSABL),NO)
obj_ap += $(RT28xx_EMBED_RPATH)/ap/ap_apcli_inf.o
endif
endif
#endif // APCLI_SUPPORT //


ifeq ($(HAS_CLIENT_WDS_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_EMBED_RPATH)/common/client_wds.o
endif

ifeq ($(HAS_IGMP_SNOOP_SUPPORT),y)
obj_ap += $(RT28xx_EMBED_RPATH)/common/igmp_snoop.o
endif

ifeq ($(HAS_BGND_SCAN_SUPPORT),y)
ifneq ($(findstring mt7615,$(CHIPSET)),)
obj_cmm += $(RT28xx_EMBED_RPATH)/common/bgnd_scan.o
endif
endif

MOD_NAME = $(MODULE)_ap
DAT_PATH = /etc/Wireless/RT$(CHIPSET_DAT)AP
DAT_FILE_NAME = conf/RT$(CHIPSET_DAT)AP.dat
endif
#endif // CONFIG_AP_SUPPORT //


###############################################################################
#
# config for STA mode
#
###############################################################################



###############################################################################
#
# config for AP/STA mixed mode
#
###############################################################################

#ifdef CONFIG_APSTA_SUPPORT
ifeq ($(RT28xx_MODE), APSTA)
MOD_NAME = $(MODULE)_apsta
endif
#endif // CONFIG_APSTA_SUPPORT //


###############################################################################
#
# Module Base
#
###############################################################################

obj-m := $(MOD_NAME).o

#ifdef CONFIG_AP_SUPPORT
ifeq ($(RT28xx_MODE),AP)

$(MOD_NAME)-objs := \
	$(obj_ap)\
	$(obj_vht)\
	$(obj_cmm)\
	$(obj_ra)\
	$(obj_wsc)\
	$(obj_phy)\
	$(obj_txbf)

#ifdef MULTI_INF_SUPPORT
ifeq ($(HAS_MULTI_INF),y)
$(MOD_NAME)-objs += $(RT28xx_RPATH)/os/linux/multi_main_dev.o
endif
#endif // MULTI_INF_SUPPORT //

#ifdef BG_FT_SUPPORT
ifeq ($(OSABL),NO)
ifeq ($(HAS_BGFP_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_RPATH)/os/linux/br_ftph.o
endif
endif
#endif // BG_FT_SUPPORT //

ifeq ($(OSABL),NO)
$(MOD_NAME)-objs += \
	$(RT28xx_EMBED_RPATH)/common/rt_os_util.o\
	$(RT28xx_RPATH)/os/linux/rt_linux.o\
	$(RT28xx_RPATH)/os/linux/rt_txrx_hook.o\
	$(RT28xx_RPATH)/os/linux/rt_main_dev.o


#ifdef CONFIG_TRACE_SUPPORT
ifeq ($(HAS_TRACE_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_RPATH)/os/linux/trace.o\

CFLAGS_trace.o = -I$(RT28xx_DIR)/include/os
endif
#endif

#ifdef CONFIG_SNIFFER_SUPPORT
ifeq ($(HAS_SNIFFER_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_EMBED_RPATH)/common/sniffer_prism.o	\
	$(RT28xx_EMBED_RPATH)/common/sniffer_radiotap.o
endif
#endif // CONFIG_SNIFFER_SUPPORT //

else
$(MOD_NAME)-objs += \
	$(RT28xx_RPATH)/os/linux/rt_symb.o
endif

#ifdef CRDA_SUPPORT
ifeq ($(OSABL),NO)
ifeq ($(HAS_CFG80211_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_util.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_scan.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_rx.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_tx.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_inf.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_p2p.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_ap.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211drv.o\
        $(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_tdls.o
endif
endif

ifeq ($(OSABL),YES)
ifeq ($(HAS_CFG80211_SUPPORT),y)
$(MOD_NAME)-objs += \
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_scan.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_rx.o\
        $(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_tx.o\
        $(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_inf.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_p2p.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211_ap.o\
	$(RT28xx_RPATH)/os/linux/cfg80211/cfg80211drv.o
endif
endif
#endif // CRDA_SUPPORT //


ifeq ($(PLATFORM),IKANOS_V160)
$(MOD_NAME)-objs += $(RT28xx_RPATH)/os/linux/vr_ikans.o
endif

ifeq ($(PLATFORM),IKANOS_V180)
$(MOD_NAME)-objs += $(RT28xx_RPATH)/os/linux/vr_ikans.o
endif

ifeq ($(PLATFORM),BL2348)
ifeq ($(OSABL),NO)
$(MOD_NAME)-objs += $(RT28xx_RPATH)/os/linux/vr_bdlt.o
endif
endif
#ifdef PLATFORM_BL23570
ifeq ($(PLATFORM),BL23570)
rt$(CHIPSET)ap-objs += \
        $(RT28xx_RPATH)/os/linux/vr_bdlt.o
endif
#endif // PLATFORM_BL23570 //

endif
#endif // CONFIG_AP_SUPPORT //


#ifdef CONFIG_APSTA_SUPPORT
ifeq ($(RT28xx_MODE), APSTA)
$(MOD_NAME)-objs := \
	$(obj_ap)\
	$(obj_sta)\
	$(obj_cmm)\
	$(obj_ra)\
	$(obj_wsc)\
	$(obj_txbf)
endif
#endif // CONFIG_APSTA_SUPPORT //


#chip releated




#ifdef MT7615
ifneq ($(findstring mt7615,$(CHIPSET)),)
$(MOD_NAME)-objs += \
		$(RT28xx_RPATH)/chips/mt7615.o\
		$(RT28xx_RPATH)/chips/mt7615_dbg.o\
		$(RT28xx_EMBED_RPATH)/mcu/mcu.o\
		$(RT28xx_EMBED_RPATH)/mcu/andes_core.o\
		$(RT28xx_EMBED_RPATH)/mcu/andes_mt.o \
		$(RT28xx_RPATH)/mcu/fw_cmd.o \
		$(RT28xx_RPATH)/mcu/fwdl.o \
		$(RT28xx_RPATH)/mcu/fwdl_mt.o \
		$(RT28xx_RPATH)/mcu/mt_cmd.o

ifeq ($(HAS_ATE),y)
#$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_ate.o
$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_testmode.o
$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_testmode_dmac.o
endif

endif
#endif // MT7615 //

#start of mt7622
ifneq ($(findstring mt7622,$(CHIPSET)),)

$(MOD_NAME)-objs += \
		$(RT28xx_RPATH)/chips/mt7622.o\
		$(RT28xx_RPATH)/chips/mt7622_dbg.o\
		$(RT28xx_EMBED_RPATH)/mcu/mcu.o\
		$(RT28xx_EMBED_RPATH)/mcu/andes_core.o\
		$(RT28xx_EMBED_RPATH)/mcu/andes_mt.o \
		$(RT28xx_RPATH)/mcu/fw_cmd.o \
		$(RT28xx_RPATH)/mcu/fwdl.o \
		$(RT28xx_RPATH)/mcu/fwdl_mt.o \
		$(RT28xx_RPATH)/mcu/mt_cmd.o

ifeq ($(HAS_ATE),y)
#$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_ate.o
$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_testmode.o
$(MOD_NAME)-objs += $(RT28xx_RPATH)/ate/mt_mac/mt_testmode_dmac.o
endif

endif
#end of mt7622

PHONY := clean install uninstall

clean:
	rm -f $(RT28xx_EMBED_RPATH)/common/*.o
	rm -f $(RT28xx_EMBED_RPATH)/common/.*.{cmd,flags,d}
	rm -f $(RT28xx_RPATH)/os/linux/*.{o,ko,mod.{o,c}}
	rm -f $(RT28xx_RPATH)/os/linux/.*.{cmd,flags,d}
	rm -fr $(RT28xx_RPATH)/os/linux/.tmp_versions
#Must clean Module.symvers; or you will suffer symbol version not match
#when OS_ABL = YES.
	rm -f $(RT28xx_RPATH)/os/linux/Module.symvers
	rm -f $(RT28xx_RPATH)/os/linux/Modules.symvers
	rm -f $(RT28xx_RPATH)/os/linux/Module.markers
	rm -f $(RT28xx_RPATH)/os/linux/modules.order
	rm -f $(RT28xx_EMBED_RPATH)/chips/*.o
	rm -f $(RT28xx_EMBED_RPATH)/chips/.*.{cmd,flags,d}
ifeq ($(RT28xx_MODE),AP)
	rm -f $(RT28xx_EMBED_RPATH)/ap/*.o
	rm -f $(RT28xx_EMBED_RPATH)/ap/.*.{cmd,flags,d}
else
ifeq ($(RT28xx_MODE),STA)
	rm -f $(RT28xx_EMBED_RPATH)/sta/*.o
	rm -f $(RT28xx_EMBED_RPATH)/sta/.*.{cmd,flags,d}
else
ifeq ($(RT28xx_MODE),APSTA)
	rm -f $(RT28xx_EMBED_RPATH)/ap/*.o
	rm -f $(RT28xx_EMBED_RPATH)/ap/.*.{cmd,flags,d}
	rm -f $(RT28xx_EMBED_RPATH)/sta/*.o
	rm -f $(RT28xx_EMBED_RPATH)/sta/.*.{cmd,flags,d}
endif
endif
endif

install:
ifeq ($(PLATFORM),INTELP6)
	rm -rf $(BUILD_DEST)/etc/Wireless/7615AP/
	mkdir -p $(BUILD_DEST)/etc/
	mkdir -p $(BUILD_DEST)/etc/Wireless/
	mkdir -p $(BUILD_DEST)/etc/Wireless/7615AP/
	#cp $(RT28xx_EMBEDDED_DIR)/conf/mt76xx_5.dat $(BUILD_DEST)/etc/Wireless/7615AP/ # ARRIS REMOVE
	#cp $(RT28xx_EMBEDDED_DIR)/conf/mt76xx_24.dat $(BUILD_DEST)/etc/Wireless/7615AP/ #ARRIS REMOVE
	#cp $(RT28xx_EMBEDDED_DIR)/RT30xxEEPROM.bin $(BUILD_DEST)/etc/Wireless/7615AP/
	cp $(RT28xx_DIR)/eeprom/MT7615E1_EEPROM.bin $(BUILD_DEST)/etc/Wireless/7615AP/MT7615_EEPROM.bin # ARRIS MOD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC.dat $(BUILD_DEST)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_ETSI.dat $(BUILD_DEST)/etc/Wireless/7615AP/ #ARRIS ADD
	chmod 777 $(BUILD_DEST)/etc/Wireless/7615AP/ -Rf
	rm -rf $(FSROOT)/etc/Wireless/7615AP/
	mkdir -p $(FSROOT)/etc/
	mkdir -p $(FSROOT)/etc/Wireless/
	mkdir -p $(FSROOT)/etc/Wireless/7615AP/
	#cp $(RT28xx_EMBEDDED_DIR)/conf/mt76xx_5.dat $(FSROOT)/etc/Wireless/7615AP/ #ARRIS REMOVE
	#cp $(RT28xx_EMBEDDED_DIR)/conf/mt76xx_24.dat $(FSROOT)/etc/Wireless/7615AP/ #ARRIS REMOVE
	#cp $(RT28xx_EMBEDDED_DIR)/RT30xxEEPROM.bin $(FSROOT)/etc/Wireless/7615AP/
	cp $(RT28xx_DIR)/eeprom/MT7615E1_EEPROM.bin $(FSROOT)/etc/Wireless/7615AP/MT7615_EEPROM.bin # ARRIS MOD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_ETSI.dat $(FSROOT)/etc/Wireless/7615AP/ #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_BF_FCC_DF.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_BF_FCC_US.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_BF_FCC_DO.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_BF_FCC_MX.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_3_TxStream_DF.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_3_TxStream_US.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_3_TxStream_DO.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_3_TxStream_MX.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_DF.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_US.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_DO.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	cp $(RT28xx_DIR)/arris_patch/new/SingleSKU_FCC_MX.dat $(FSROOT)/etc/Wireless/7615AP/  #ARRIS ADD
	chmod 777 $(BUILD_DEST)/etc/Wireless/7615AP -Rf
ifeq ($(RT28xx_MODE),AP)
ifeq ($(PLATFORM),INTELP6)
	install -d $(BUILD_DEST)/lib/modules/wifi/
	install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(BUILD_DEST)/lib/modules/wifi/
	install -d $(FSROOT)/lib/modules/wifi/
	install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(FSROOT)/lib/modules/wifi/
endif
endif
else
	rm -rf $(DAT_PATH)
	$(shell [ ! -f /etc/Wireless ] && mkdir /etc/Wireless)
	mkdir $(DAT_PATH)
	cp $(RT28xx_EMBEDDED_DIR)/$(DAT_FILE_NAME) $(DAT_PATH)/.
	install -d $(LINUX_SRC_MODULE)
	install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(LINUX_SRC_MODULE)
	/sbin/depmod -a ${shell uname -r}
endif

uninstall:
#	rm -rf $(DAT_PATH)
	rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .ko,$(MOD_NAME)))
	/sbin/depmod -a ${shell uname -r}

# Declare the contents of the .PHONY variable as phony.  We keep that
# information in a variable so we can use it in if_changed and friends.
.PHONY: $(PHONY)
